package game.physics;

import java.awt.Point;


/**
 * Example of how you can subclass the GameVector to add important new behavior
 * such as a impulse force used in collisions
 * 
 * @author Ben Schwab
 * 
 */
public class ImpulseVector extends GameVector {
    private double myDuration;

    /**
     * Creates a new vector.
     * 
     * @param x x value of vector
     * @param y y value of vector
     * @param duration in seconds of the vector
     */
    public ImpulseVector(double x, double y, double duration) {
        super(x, y);
        myDuration = duration;
    }

    /**
     * Creates a new vector defined by the coordinates
     * of its head and tail.
     * 
     * @param tail
     * @param head
     * @param duration The duration which the ImpulseVector
     *        should last for.
     */
    public ImpulseVector(Point tail, Point head, double duration) {
        super(tail, head);
        myDuration = duration;
    }

    public ImpulseVector (GameVector gameVector, double duration) {
        super(gameVector);
        myDuration = duration;
    }

    /**
     * 
     * @return returns if the vector is active (has time left)
     */
    public boolean isActive() {
        return myDuration > 0;
    }

    /**
     * decrease the time remaining on this vector
     * 
     * @param duration The decrease in the amount
     *        of time that the ImpulseVector should last
     *        for.
     */
    public void decreaseDuration(double duration) {
        myDuration -= duration;
    }

}
